import {
	defineConfig
} from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {
	ElementPlusResolver
} from 'unplugin-vue-components/resolvers'
import {
	resolve
} from 'path'
import vueJsx from "@vitejs/plugin-vue-jsx"
import config from './config/env.js'
import { fileURLToPath, URL } from "node:url";
import { svgBuilder } from "./src/plugins/svgBuilder";

export default defineConfig({
	plugins: [
		vue(),
		svgBuilder("./src/assets/icons/svg/"),
		vueJsx(),
		AutoImport({
			resolvers: [
				// 自动导入 Element Plus 组件
				ElementPlusResolver()
			],
		}),
		Components({
			resolvers: [
				// 自动导入 Element Plus 组件
				ElementPlusResolver()
			],
		}),
	],
	//去掉所有console debugger
	esbuild:{
		drop: ['console', 'debugger']
	},
	css: {
		postcss: {
			plugins: []
		}
	},
	server: {
		/* host: '192.168.3.14',
		port: '5173', */
		proxy: {
			// '/api': {
			// 	target: config.API_BASE_URL + '/api',
			// 	ws: true,
			// 	changeOrigin: true,
			// 	rewrite: (path) => path.replace(/^\/api/, '')
			// },
			'/v1': {
				target: config.API_BASE_URL + '/v1',
				ws: true,
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/v1/, '')
			}
		}
	},
	resolve: {
		//路径配置@符号识别
		// zwy配置
		alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
		// 罗阳配置
		// alias: {
		// 	"@": resolve(__dirname, "./src"),
		// }
	}
})